home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / bluebook.zip / BINARY.DOC < prev    next >
Text File  |  1986-05-08  |  9KB  |  240 lines

  1.  
  2. BINARY.DOC -- Description of BINARY.ASM
  3. =======================================
  4.  
  5.   From `BLUEBOOK of ASSEMBLY ROUTINES for the IBM PC & XT'
  6.         by Christopher L. Morgan
  7.         Copyright (C) 1984 by The Waite Group, Inc.
  8.  
  9.   Purpose: BINARY.ASM contains routines to convert between number bases. 
  10.  
  11.      Contents:
  12.      ---------
  13.      BIN16IN    --  Convert from ASCII Binary to 16-bit Binary
  14.      BIN16OUT    --  Convert from 16-bit Binary to ASCII Binary
  15.      BIN8OUT    --  Convert from 8-bit Binary to ASCII Binary
  16.      DEC16IN    --  Convert from ASCII Decimal to 16-bit Binary       
  17.      DEC16OUT    --  Convert from 16-bit Binary to ASCII Decimal
  18.      DEC8OUT    --  Convert from 8-bit Binary to ASCII Decimal
  19.      HEX16IN    --  Convert from ASCII Hexadecimal to 16-bit Binary
  20.      HEX16OUT    --  Convert from 16-bit Binary to ASCII Hexadecimal
  21.      HEX8OUT    --  Convert from 8-bit Binary to ASCII Hexadecimal
  22.      OCT16IN    --  Convert from ASCII Octal to 16-bit Binary
  23.      OCT16OUT    --  Convert from 16-bit Binary to ASCII Octal
  24.      OCT8OUT    --  Convert from 8-bit Binary to ASCII Octal
  25.         
  26.   Overview: These routines perform conversion between the PC's 8- and 16-bit
  27.     internal BINARY integer formats and all the popular external integer
  28.     number bases: binary, octal, hexadecimal, and decimal.  For each number
  29.     base, there are three routines:
  30.  
  31.         1) Input from external to 16-bit binary internal format
  32.         2) Output from 8-bit binary internal format to external
  33.         3) Output from 16-bit binary internal format to external
  34.  
  35.     Throughout the routines, the 8088 registers are used consistently:
  36.  
  37.          AX is used for quick calculations and data movement
  38.         CL & CX are used for counting, multiplying, or dividing
  39.         DL & DX are used to pass numerical data in and out of routines
  40.  
  41. ________________________________ BINARY ROUTINES ______________________________
  42.  
  43. BIN16IN -- Convert from ASCII Binary to 16-bit Binary
  44.  
  45.   Function: This routine accepts a binary number from the standard input
  46.     device and converts it to internal 16-bit binary form.
  47.  
  48.   Input: The individual digits of the binary number are received in ASCII
  49.     through a call to a standard I/O routine.  The valid digits are 0 and 1.
  50.     An ASCII code other than for a valid digit will terminatete the routine.
  51.  
  52.   Output: A 16-bit binary number is returned in the DX register.
  53.  
  54.   Registers used: Only DX is modified.  It returns the result.
  55.  
  56.   Routines called: STDIN
  57. ______________________________________________________________________________
  58.  
  59. BIN8OUT
  60.  
  61.   Function: This routine accepts an 8-bit binary number in the DL register,
  62.     converts it to ASCII binary form, and sends it to the standard output
  63.     device.
  64.  
  65.   Input: Upon entry an 8-bit binary number is in the DL register.
  66.  
  67.   Output: A string of ASCII digits representing a binary number is sent out
  68.     through the standard output device.
  69.  
  70.   Registers used: No registers are modified. DL is used for input.
  71.  
  72.   Routines called:  STDOUT
  73. ______________________________________________________________________________
  74.  
  75. BIN16OUT
  76.  
  77.   Function: This routine accepts a 16-bit binary number in the DX register,
  78.     converts it to ASCII binary form, and sends it to the standard output
  79.     device.
  80.  
  81.   Input: Upon entry a 16-bit binary number is in the DX register.
  82.  
  83.   Output: A string of ASCII digits representing a binary number is sent out
  84.     through the standard output device.
  85.  
  86.   Registers used: No registers are modified. DX is used for input.
  87.  
  88.   Routines called: STDOUT
  89. ______________________________________________________________________________
  90.  
  91. OCT16IN
  92.  
  93.   Function: This routine accepts an octal number from the standard input
  94.     device and converts it to internal 16-bit binary form.
  95.  
  96.   Input: The individual digits of the octal number are received in ASCII
  97.     through a call to a standard I/O routine.  The valid digits are
  98.     0 through 7. An ASCII code other than for a valid digit will terminate
  99.     the routine.
  100.  
  101.   Output: A 16-bit binary number is returned in the DX register.
  102.  
  103.   Registers used: Only DX is modified. It returns the result.
  104.  
  105.   Routines called: STDIN
  106. ______________________________________________________________________________
  107.  
  108. OCT8OUT
  109.  
  110.   Function: This routine accepts an 8-bit binary number in the DL register,
  111.     converts it to ASCII octal form and sends it to the standard output device.
  112.  
  113.   Input: Upon entry an 8-bit binary number is in the DL register.
  114.  
  115.   Output: A string of ASCII digits representing an Octal number is sent out
  116.     through the standard output device.
  117.  
  118.   Registers used: No registers are modified. DL is used for input.
  119.  
  120.   Routines called: STDOUT
  121. ______________________________________________________________________________
  122.  
  123. OCT16OUT
  124.  
  125.   Function: This routine accepts 16-bit binary number in the DX register,
  126.     converts it to ASCII octal form and sends it to the standard output device.
  127.  
  128.   Input: Upon entry a 16-bit binary number is in the DX register.
  129.  
  130.   Output: A string of ASCII digits representing an octal number is sent out
  131.     through the standard output device.
  132.  
  133.   Registers used: No registers are modified. DX is used for input.
  134.  
  135.   Routines called: STDOUT
  136. ______________________________________________________________________________
  137.  
  138. HEX16IN
  139.  
  140.   Function: This routine accepts a hexadecimal number from the standard input
  141.     device and converts it to internal 16-bit binary form.
  142.  
  143.   Input: The individual digits of the hexadecimal number are received in ASCII
  144.     through a call to a standard I/O routine. The valid digits are 0 through 9
  145.     and A through F. An ASCII code other than for a valid digit will terminate
  146.     the routine.
  147.  
  148.   Output: A 16-bit binary number is returned in the DX register.
  149.  
  150.   Registers usnd: Only DX is modified. It returns the result.
  151.  
  152.   Routines called: STDIN
  153. ______________________________________________________________________________
  154.  
  155. HEX8OUT
  156.  
  157.   Function:  This routine accepts an 8-bit binary number in the DL register,
  158.     converts it to ASCII hexadecimal form and sends it to the standard output
  159.     device.
  160.  
  161.   Input: Upon entry an 8-bit binary number is in the DL register.
  162.  
  163.   Output: A string of ASCII digits representing a hexadecimal number is sent
  164.     out through the standard output device.
  165.  
  166.   Registers used: No registers are modified. DL is used for input.
  167.  
  168.   Routines called: STDOUT
  169. ______________________________________________________________________________
  170.  
  171. HEX16OUT
  172.  
  173.   Function: This routine accepts a 16-bit binary number in the DX register,
  174.     converts it to ASCII hexadecimal form and sends it to the standard output
  175.     device.
  176.  
  177.   Input: Upon entry a 16-bit binary number is in the DX register.
  178.  
  179.   Output: A string of ASCII digits representing a hexadecimal number is sent
  180.     out through the standard output device.
  181.  
  182.   Registers used: No registers are modified. DX is used for input.
  183.  
  184.   Routines called: STDOUT
  185. ______________________________________________________________________________
  186. _
  187. DEC16IN
  188.  
  189.   Function: This routine accepts a decimal number from the standard input
  190.     device and converts it to internal 16-bit binary form.
  191.  
  192.   Input: The individual digits of the decimal number are received in ASCII
  193.     through a call to a standard I/O routine.  The valid digits are
  194.     0 through 0. An ASCII code other than for a valid digit will terminate
  195.    the routine.
  196.  
  197.   Output: A 16-bit binary number is returned in the DX register.
  198.  
  199.   Registers used: Only DX is modified. It returns the result.
  200.  
  201.   Routines called: STDIN
  202. ______________________________________________________________________________
  203.  
  204. DEC8OUT
  205.  
  206.   Function: This routine accepts an 8-bit binary number in the DL register,
  207.     converts it to ASCII decimal form and sends it to the standard output
  208.     device.
  209.  
  210.   Input: Upon entry an 8-bit binary number is in the DL register.
  211.  
  212.   Output: A string of ASCII digits representing a decimal number is stored in
  213.     a buffer called TBUFF and then sent out through the standard output device.
  214.  
  215.   Registers used: No registers are